/*****************************************************************************
 * Copyright (c) 2019, Nations Technologies Inc.
 *
 * All rights reserved.
 * ****************************************************************************
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *
 * - Redistributions of source code must retain the above copyright notice,
 * this list of conditions and the disclaimer below.
 *
 * Nations' name may not be used to endorse or promote products derived from
 * this software without specific prior written permission.
 *
 * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY NATIONS "AS IS" AND ANY EXPRESS OR
 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
 * DISCLAIMED. IN NO EVENT SHALL NATIONS BE LIABLE FOR ANY DIRECT, INDIRECT,
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
 * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 * ****************************************************************************/

/**
 * @file n32wb452x_it.h
 * @author Nations
 * @version v1.0.1
 *
 * @copyright Copyright (c) 2019, Nations Technologies Inc. All rights reserved.
 */
#ifndef __N32WB452_IT_H__
#define __N32WB452_IT_H__

#ifdef __cplusplus
extern "C" {
#endif

#include "n32wb452.h"

#define PRINT_CPU_FAULT_INFO(flag)                                                  \
    {                                                                               \
        uint32_t* stack_top = (uint32_t*)__get_MSP();                               \
        printf("**************%s ERROR:REG INFO**************.\r\n", flag);         \
        printf("msp = 0x%08x.\r\n", stack_top);                                     \
        printf("r0  = 0x%08x,   \tr1   = 0x%08x.\r\n", stack_top[0], stack_top[1]); \
        printf("r2  = 0x%08x,   \tr3   = 0x%08x.\r\n", stack_top[2], stack_top[3]); \
        printf("r12 = 0x%08x,   \tlr   = 0x%08x.\r\n", stack_top[4], stack_top[5]); \
        printf("pc  = 0x%08x,   \txpsr = 0x%08x.\r\n", stack_top[6], stack_top[7]); \
    }

void NMI_Handler(void);
void HardFault_Handler(void);
void MemManage_Handler(void);
void BusFault_Handler(void);
void UsageFault_Handler(void);
void SVC_Handler(void);
void DebugMon_Handler(void);
void PendSV_Handler(void);
void SysTick_Handler(void);

#ifdef __cplusplus
}
#endif

#endif /* __N32WB452X_IT_H__ */
/**
 * @}
 */

/**
 * @}
 */

/**
 * @}
 */
